package ch.christianschweizer.epk.common.utils;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;

import oracle.adf.share.logging.ADFLogger;


public class MessageUtil {

    private static final ADFLogger logger = ADFLogger.createADFLogger(MessageUtil.class);
    private static Map<String, ResourceBundle> cache = new HashMap<String, ResourceBundle>();

    public static ResourceBundle getBundle(String baseName, Locale locale) {
        String key = baseName + (locale != null ? "_" + locale.getLanguage() : "");

        if (cache.containsKey(key)) {
            return cache.get(key);
        } else {
            ResourceBundle bundle =
                locale != null ? ResourceBundle.getBundle(baseName, locale) : ResourceBundle.getBundle(baseName);
            cache.put(key, bundle);
            return bundle;
        }
    }

}
